#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/12 20:43
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : addschedule_page.py
# @Project : crm
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from selenium.webdriver.support.select import Select
from utils.util import HS3
"""添加日程页面"""
class AddSchedule(BasePage):
    """添加日程页面，一系列定位器以及操作方法"""
    url = "{}/crm3/index.php?m=event".format(HS3)
    """定位器"""
    schedule_theme_locator = (By.ID, 'subject')  # 日程主题
    start_date_locator = (By.ID, 'start_date')  # 日程开始时间
    adress_locator = (By.ID, 'venue')  # 日程地点
    end_date_locator = (By.ID, 'end_date')  # 日程结束时间
    select1_locator = (By.ID, 'select1')  # 选择相关下拉框
    module_name_locator = (By.ID, 'module_name')  # 联系人选项
    contact_locator = (By.XPATH, '/html/body/div[8]/div[2]/table/tbody[2]/tr/td[1]/input')  # 选择吊炸天
    schedule_ok_locator = (By.XPATH, '/html/body/div[8]/div[3]/div/button[1]/span')  # 确认按钮
    description_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[2]/textarea')  # 描述输入框
    schedule_submit_locator = (By.CSS_SELECTOR, 'input[value="保存"]')  # 保存按钮
    def input_theme(self,theme):
        """输入主题"""
        self.driver.find_element(*self.schedule_theme_locator).send_keys(theme)
    def clear_theme(self):
        """输入主题"""
        self.driver.find_element(*self.schedule_theme_locator).clear()
    def start_date(self,start_date):
        """输入开始日期"""
        self.driver.find_element(*self.start_date_locator).send_keys(start_date)
    def adress(self,adress):
        """输入日程地点"""
        self.driver.find_element(*self.adress_locator).send_keys(adress)
    def end_date(self,end_date):
        """日程结束时间"""
        self.driver.find_element(*self.end_date_locator).send_keys(end_date)
    def select1(self):
        """选择下拉框里面的联系人"""
        Select(self.driver.find_element(*self.select1_locator)).select_by_value('contacts')
    def module_name(self):
        """点击联系人后面的输入框"""
        self.driver.find_element(*self.module_name_locator).click()
    def contact(self):
        """选择客户吊炸天"""
        self.driver.find_element(*self.contact_locator).click()
    def ok_schedule(self):
        """点击ok按钮"""
        self.driver.find_element(*self.schedule_ok_locator).click()
    def description(self,description):
        """输入描述"""
        self.driver.find_element(*self.description_locator).send_keys(description)
    def schedule_submit(self):
        """点击保存日程"""
        self.driver.find_element(*self.schedule_submit_locator).click()

